#include <gtk/gtk.h>
#include <stdio.h>

#include "gtkutils.h"
#include "stringutils.h"
#include "logs/log.h"

int i = 0;
guint timer = 0;

static bool timer_hander(GtkLabel *label) {
    char fuck[100] = {0};
    sprintf(fuck, "当前计数：%d",i);

    gtk_label_set_text(label, fuck);

    i++;
    return true;
}

void cleari(GtkLabel *label) {
    i = 0;
    timer_hander(label);
}

void start(GtkLabel *label) {
    if (stopTimer(&timer))
    timer = createTimerMilliSecond(100, timer_hander, label);
}

void stop() {
    stopTimer(&timer);
}

void sayHello() {
    DEBUG_LOG("Hello");
}

void sayExit(GtkWindow *window){
    gtk_window_close(window);
}

static void activate(GtkApplication *app, gpointer user_data) {
    GtkWindow *window = createWindowWithTitleSize(app, "template", 200, 100);

    GtkBox *box = createBoxWithVertical(10);
    setBoxFullMargin(box, 40);

    boxAppend(box, createLabel("Hello World"));
    
    setWindowChild(window, box);
    showWindow(window);
}

int	main(int argc, char **argv) {

    GtkApplication *app;
    int status;

    app = createApplicationConnectActivate("gtk.example.template", 
                                G_APPLICATION_FLAGS_NONE, activate);
    status = runApplication(app, argc, argv);
    objectUnref(app);

    return status;
}

